﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace FRW.Common.Extensions
{
    public static class HTTPWebRequestExtensions
    {
        public static void AddAuthorizationHeader(this HttpWebRequest request, string username, string password)
        {
            string credentials = String.Format("{0}:{1}", username, password);
            byte[] bytes = Encoding.ASCII.GetBytes(credentials);
            string base64 = Convert.ToBase64String(bytes);
            //string base64 = credentials; 
            string authorization = String.Concat("Basic ", base64);

            request.Headers.Add("Authorization", authorization);
        }

    }
}
